package hw.ats.news.activity.ats;

import hw.ats.news.R;
import hw.ats.news.ui.BottomTabHostProvider;
import hw.ats.news.ui.CommonUI;
import hw.ats.news.util.App;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.humanwares.ui.tabbar.TabHost;

public class AtsInfoAct extends Activity {
	@SuppressWarnings("unused")
	private final static String TAG = "AtsInfoAct";
	private TabHost navbar = null;
	private ProgressDialog progressDialog;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        setContentView(R.layout.act_ats_info);
        
        // 탭바 초기화
        navbar = CommonUI.renderTabBar(this, BottomTabHostProvider.TAB5);
		
		// 네이게이션바 제목
        CommonUI.renderAppTitle(this);
        
        // 좌측 네비게이션 버튼 = 이전화면 이동
        CommonUI.addLeftNavigationButtonBackEvent(this);
        
        final WebView htmlView = (WebView)findViewById(R.id.view_html);
        htmlView.getSettings().setJavaScriptEnabled(true);
        
        htmlView.getSettings().setDefaultZoom(ZoomDensity.FAR);
        htmlView.setWebViewClient(new WebViewClient() {
			@Override
			public void onPageFinished(WebView view, String url) {
				super.onPageFinished(view, url);
				progressDialog.dismiss();
			}

			@Override
			public void onReceivedError(WebView view, int errorCode,
					String description, String failingUrl) {
				super.onReceivedError(view, errorCode, description, failingUrl);
				progressDialog.dismiss();
			}
        });
        htmlView.loadUrl(App.ATS_HOME_URL);
        
		progressDialog = new ProgressDialog(this);
		progressDialog.setMessage("잠시만 기다려주십시오.");
		progressDialog.setIndeterminate(true);
		progressDialog.setCancelable(true);
		progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		progressDialog.show();
    }
    
    @Override
	protected void onDestroy() {
		super.onDestroy();
	}
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        int visibility = navbar.getVisibility();
        navbar.setVisibility(visibility == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
        return false;
    }
}
